;solution for euler 20

(defun ctod (char)
	(if (typep char 'number)
		(return-from ctod char)
		(return-from ctod (- (char-code char) (char-code #\0)))))
	
;;originally from eu8
(defun eu20-add-digits (seq)
	(reduce #'(lambda (a b) (+ (ctod a) (ctod b))) seq))

(defun recu-facto (n) 
	(if (> n 1)
		(return-from recu-facto (* (recu-facto (- n 1)) n))
		(return-from recu-facto 1)))

(defun solve-euler20 ()
	(format t "Euler 20: ~a" (eu20-add-digits (write-to-string (recu-facto 100)))))
	
	